package com.ruoyi.member.api.facotry;

import com.ruoyi.member.api.RemoteWxUserService;
import com.ruoyi.member.api.domain.WxUser;
import com.ruoyi.common.core.domain.R;
import org.slf4j.Logger;
import org.slf4j.LoggerFactory;
import org.springframework.cloud.openfeign.FallbackFactory;
import org.springframework.stereotype.Component;

import java.util.List;

/**
 * 用户服务降级处理
 * 
 * @author ruoyi
 */
@Component
public class RemoteWxUserFallbackFactory implements FallbackFactory<RemoteWxUserService>
{
    private static final Logger log = LoggerFactory.getLogger(RemoteWxUserFallbackFactory.class);

    @Override
    public RemoteWxUserService create(Throwable throwable)
    {
        log.error("会员服务调用失败:{}", throwable.getMessage());
        return new RemoteWxUserService()
        {
            @Override
            public R<List<WxUser>> userList(String source) {
                return R.fail("获取会员失败:" + throwable.getMessage());
            }
        };
    }
}
